let api = [];
api.push({
    alias: 'api',
    order: '1',
    desc: '',
    link: '',
    list: []
})
api[0].list.push({
    order: '1',
    methodId: 'fd8afe759a1e8500da995ca00674678b',
    desc: '',
});
api[0].list.push({
    order: '2',
    methodId: 'c629101f1d8d59fb62724d9d1548bccb',
    desc: '',
});
api[0].list.push({
    order: '3',
    methodId: '6c395ddf45ddc30db293d54e81f3efb2',
    desc: '',
});
api[0].list.push({
    order: '4',
    methodId: 'f98cc7383faa69ca59328244f3ec6f8c',
    desc: '',
});
api[0].list.push({
    order: '5',
    methodId: '7ff02d3b03255b2aa2d0a68f7787d07c',
    desc: '',
});
api[0].list.push({
    order: '6',
    methodId: 'd148d7035c6deb31b99b0630d5cef9f9',
    desc: '',
});
api.push({
    alias: 'UserController',
    order: '2',
    desc: '',
    link: '',
    list: []
})
api[1].list.push({
    order: '1',
    methodId: '8a686e15d148879ab9aef876d909926e',
    desc: '查询所有用户',
});
api[1].list.push({
    order: '2',
    methodId: '69c93c5da88371cfd4176d923f7ddfe3',
    desc: '根据信息查询用户',
});
api[1].list.push({
    order: '3',
    methodId: '714506f2f3e4b774d4db5093ad63b393',
    desc: '根据id查询用户',
});
api[1].list.push({
    order: '4',
    methodId: '8a80bc51b3e63dfb94493385a7f732d2',
    desc: '保存用户信息',
});
api[1].list.push({
    order: '5',
    methodId: '156174d1e97ed76327e64fdee02d5e35',
    desc: '删除用户信息',
});
api[1].list.push({
    order: '6',
    methodId: '2875ef3ec298b1cd739e36285777067d',
    desc: '更新用户信息',
});
api[1].list.push({
    order: '7',
    methodId: '5ffdedeb4a6e740070af23a268e3693a',
    desc: '登录',
});
api.push({
    alias: 'NewsController',
    order: '3',
    desc: '',
    link: '',
    list: []
})
api[2].list.push({
    order: '1',
    methodId: 'b5ff673d86a1be30087665f7bde0ca93',
    desc: '查询所有新闻',
});
api[2].list.push({
    order: '2',
    methodId: '46227e79e02f4428949120d8932cfbca',
    desc: '根据作者查询新闻',
});
api[2].list.push({
    order: '3',
    methodId: '2b9209658731c28e200ccc36c7189c84',
    desc: '删除新闻信息',
});
api[2].list.push({
    order: '4',
    methodId: '88de9748e209e7ac312d6af765154e23',
    desc: '增加新闻信息',
});
api[2].list.push({
    order: '5',
    methodId: 'd7265a8a6ed55e894f0218c7e520b1db',
    desc: '更新新闻信息',
});
api[2].list.push({
    order: '6',
    methodId: 'b9bb408c7ecf6393429f2f090aaaaf24',
    desc: '根据id查询数据',
});
api.push({
    alias: 'TestController',
    order: '4',
    desc: '{@code @Author} lyq  {@code @Date} 6/6/2024 10:05 PM',
    link: '{@code_@author}_lyq  {@code_@date}_6/6/2024_10:05_pm',
    list: []
})
api[3].list.push({
    order: '1',
    methodId: '894336458e1d2339a689656a06604118',
    desc: '',
});
api[3].list.push({
    order: '2',
    methodId: 'c6e30980333f8e310fdce1e0beae0a67',
    desc: '',
});
api[3].list.push({
    order: '3',
    methodId: '988c809e8a14d37ea9a14cccbf24c52e',
    desc: '',
});
api.push({
    alias: 'RoleController',
    order: '5',
    desc: '',
    link: '',
    list: []
})
api[4].list.push({
    order: '1',
    methodId: '85606d3aa86df6450e0af253e73a0964',
    desc: '查询所有角色信息',
});
api[4].list.push({
    order: '2',
    methodId: 'f6ccd8fcfeed65621a5fe5d0a9322e9e',
    desc: '根据角色名称查询',
});
api[4].list.push({
    order: '3',
    methodId: '0a3a82bb642f2d8e2d13eecc6f90f17b',
    desc: '删除角色信息',
});
api[4].list.push({
    order: '4',
    methodId: '159ae8ef92293aecb7761377d3709d6a',
    desc: '添加角色信息',
});
api[4].list.push({
    order: '5',
    methodId: '6248480e05a10daaeb5d5bae557ecab6',
    desc: '更新角色信息',
});
api[4].list.push({
    order: '6',
    methodId: '1be37fb1c9bfc52092f926f6fa89ace9',
    desc: '根据id查询数据',
});
api.push({
    alias: 'RouteController',
    order: '6',
    desc: '{@code @Author} lyq  {@code @Date} 6/13/2024 7:23 PM',
    link: '{@code_@author}_lyq  {@code_@date}_6/13/2024_7:23_pm',
    list: []
})
api[5].list.push({
    order: '1',
    methodId: '9b427db791ce81e115b14ae4c3a9b6a7',
    desc: '查询所有线路',
});
api[5].list.push({
    order: '2',
    methodId: '9085cd18d809224c937746b79e00d19d',
    desc: '根据站点名称查询线路',
});
api[5].list.push({
    order: '3',
    methodId: '41db815d25e5b80b527cd087a5bf9f32',
    desc: '添加线路',
});
api[5].list.push({
    order: '4',
    methodId: 'def039a3d5e142894118c6a43aac49f5',
    desc: '删除路线',
});
api[5].list.push({
    order: '5',
    methodId: 'aa8de33c6d4269f81bd9f1b70893aeb8',
    desc: '更新路线',
});
api[5].list.push({
    order: '6',
    methodId: '9d62a703c21974b00716d8397c4231ac',
    desc: '根据id查询线路',
});
api.push({
    alias: 'DriverController',
    order: '7',
    desc: '',
    link: '',
    list: []
})
api[6].list.push({
    order: '1',
    methodId: 'bb4ae452e8c348e903010503a4484d16',
    desc: '查询所有司机信息',
});
api[6].list.push({
    order: '2',
    methodId: '01e7bed6a866da153aa20385e725dbf6',
    desc: '根据信息查询司机',
});
api[6].list.push({
    order: '3',
    methodId: '677a56c4d293ddded99272a5961f477c',
    desc: '根据信息查询司机',
});
api[6].list.push({
    order: '4',
    methodId: 'e5c840ff295d6371b852d92591f8bbe7',
    desc: '根据信息增加司机',
});
api[6].list.push({
    order: '5',
    methodId: '935189e8c87ce93e6c8ef4bd64ee9904',
    desc: '删除站点信息',
});
api[6].list.push({
    order: '6',
    methodId: '400cb4b496c4b78b388385ed4191226e',
    desc: '根据信息更新司机',
});
api.push({
    alias: 'ScheduleController',
    order: '8',
    desc: '',
    link: '',
    list: []
})
api[7].list.push({
    order: '1',
    methodId: '55b66c10d141003d4e8b802d5d8fabe7',
    desc: '',
});
api[7].list.push({
    order: '2',
    methodId: '9a607f5f02eaa63c13e8f748b91d5a54',
    desc: '根据信息查询司机',
});
api[7].list.push({
    order: '3',
    methodId: '50f12ac5097eda57d109168af9be1000',
    desc: '根据信息查询司机',
});
api[7].list.push({
    order: '4',
    methodId: '3929e2dceafa41360993d8c0fb1a9580',
    desc: '',
});
api.push({
    alias: 'BusController',
    order: '9',
    desc: '',
    link: '',
    list: []
})
api[8].list.push({
    order: '1',
    methodId: 'd7c20a236f703a7daf84a5c692c24062',
    desc: '查询所有公交车信息',
});
api[8].list.push({
    order: '2',
    methodId: '845ff355d192ab6f728fccee72e3e2aa',
    desc: '根据id查询公交车信息',
});
api[8].list.push({
    order: '3',
    methodId: 'dad4aef32ec7ea608701f1818ea6396d',
    desc: '更新公交车信息',
});
api[8].list.push({
    order: '4',
    methodId: 'a58478d66d0accc1e7330a35e8f3fa92',
    desc: '根据站点查询公交车',
});
api[8].list.push({
    order: '5',
    methodId: 'f995133dccf1b06a367275f982d135c3',
    desc: '根据车牌号查询车辆',
});
api[8].list.push({
    order: '6',
    methodId: '3af5d5da2f4d72416158bd40770a58ec',
    desc: '添加公交车信息',
});
api[8].list.push({
    order: '7',
    methodId: 'd82a5e4d6cacb7ad9c516f71bc51c7fc',
    desc: '删除公交车信息',
});
api.push({
    alias: 'PointController',
    order: '10',
    desc: '',
    link: '',
    list: []
})
api[9].list.push({
    order: '1',
    methodId: 'dde29c4b867765d92ef95ccee2c509f0',
    desc: '查询所有站点信息',
});
api[9].list.push({
    order: '2',
    methodId: '48487e64844b4106ffe2c77af1ec19a4',
    desc: '根据信息查询站点',
});
api[9].list.push({
    order: '3',
    methodId: '8f7970564c61b1df38cf7729b0ec8042',
    desc: '根据id查询站点',
});
api[9].list.push({
    order: '4',
    methodId: 'c720c67d07200ed607bf979ded0e5311',
    desc: '保存站点信息',
});
api[9].list.push({
    order: '5',
    methodId: 'adc0436783b71e4070683fc219063430',
    desc: '删除站点信息',
});
api[9].list.push({
    order: '6',
    methodId: '6fd4e131e1382388eeb3c6f5b08b9836',
    desc: '更新站点信息',
});
document.onkeydown = keyDownSearch;
function keyDownSearch(e) {
    const theEvent = e;
    const code = theEvent.keyCode || theEvent.which || theEvent.charCode;
    if (code === 13) {
        const search = document.getElementById('search');
        const searchValue = search.value;
        let searchArr = [];
        for (let i = 0; i < api.length; i++) {
            let apiData = api[i];
            const desc = apiData.desc;
            if (desc.toLocaleLowerCase().indexOf(searchValue) > -1) {
                searchArr.push({
                    order: apiData.order,
                    desc: apiData.desc,
                    link: apiData.link,
                    alias: apiData.alias,
                    list: apiData.list
                });
            } else {
                let methodList = apiData.list || [];
                let methodListTemp = [];
                for (let j = 0; j < methodList.length; j++) {
                    const methodData = methodList[j];
                    const methodDesc = methodData.desc;
                    if (methodDesc.toLocaleLowerCase().indexOf(searchValue) > -1) {
                        methodListTemp.push(methodData);
                        break;
                    }
                }
                if (methodListTemp.length > 0) {
                    const data = {
                        order: apiData.order,
                        desc: apiData.desc,
                        alias: apiData.alias,
                        link: apiData.link,
                        list: methodListTemp
                    };
                    searchArr.push(data);
                }
            }
        }
        let html;
        if (searchValue === '') {
            const liClass = "";
            const display = "display: none";
            html = buildAccordion(api,liClass,display);
            document.getElementById('accordion').innerHTML = html;
        } else {
            const liClass = "open";
            const display = "display: block";
            html = buildAccordion(searchArr,liClass,display);
            document.getElementById('accordion').innerHTML = html;
        }
        const Accordion = function (el, multiple) {
            this.el = el || {};
            this.multiple = multiple || false;
            const links = this.el.find('.dd');
            links.on('click', {el: this.el, multiple: this.multiple}, this.dropdown);
        };
        Accordion.prototype.dropdown = function (e) {
            const $el = e.data.el;
            let $this = $(this), $next = $this.next();
            $next.slideToggle();
            $this.parent().toggleClass('open');
            if (!e.data.multiple) {
                $el.find('.submenu').not($next).slideUp("20").parent().removeClass('open');
            }
        };
        new Accordion($('#accordion'), false);
    }
}

function buildAccordion(apiData, liClass, display) {
    let html = "";
    if (apiData.length > 0) {
         for (let j = 0; j < apiData.length; j++) {
            html += '<li class="'+liClass+'">';
            html += '<a class="dd" href="#' + apiData[j].alias + '">' + apiData[j].order + '.&nbsp;' + apiData[j].desc + '</a>';
            html += '<ul class="sectlevel2" style="'+display+'">';
            let doc = apiData[j].list;
            for (let m = 0; m < doc.length; m++) {
                html += '<li><a href="#' + doc[m].methodId + '">' + apiData[j].order + '.' + doc[m].order + '.&nbsp;' + doc[m].desc + '</a> </li>';
            }
            html += '</ul>';
            html += '</li>';
        }
    }
    return html;
}